#pragma once
#include "afxcmn.h"
#include "ChatClientBaseDlg.h"
#include "UDPProxyClient.h"
// CChatClientDlg dialog



class CChatRoomClientDlg 
	: public CChatClientBaseDlg
	, public RakNet::UDPProxyClientResultHandler
{
	CListCtrl		m_chatOutput;
	CString			m_chatInput;
	SystemAddress	m_lobbyServerAddress;
	SystemAddress	m_coordinatorServerAddress;
	SystemAddress	m_proxyServerAddress;
	CListCtrl		m_joinedUsers;
	
	DECLARE_DYNAMIC(CChatRoomClientDlg)
	
public:
	CChatRoomClientDlg(CWnd* pParent = NULL);   // standard constructor
	virtual ~CChatRoomClientDlg();

// Dialog Data
	enum { IDD = IDD_DIALOG_CHATCLIENT_ROOM };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	void registerUserAddressToListCtrl( const RakNetGUID& userGuid, const SystemAddress& userAddress);
	virtual void OnForwardingSuccess(const char *proxyIPAddress, unsigned short proxyPort, unsigned short reverseProxyPort,
		SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)override;

	virtual void OnForwardingNotification(const char *proxyIPAddress, unsigned short proxyPort, unsigned short reverseProxyPort,
		SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)override;

	virtual void OnNoServersOnline(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)override;

	virtual void OnRecipientNotConnected(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNetGUID targetGuid, RakNet::UDPProxyClient *proxyClientPlugin)override;

	virtual void OnAllServersBusy(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)override;

	virtual void OnForwardingInProgress(SystemAddress proxyCoordinator, SystemAddress sourceAddress, SystemAddress targetAddress, RakNet::UDPProxyClient *proxyClientPlugin)override;

	DECLARE_MESSAGE_MAP()
public:
	
	afx_msg void	OnBnClickedButtonSend();
	virtual BOOL	OnInitDialog();
	void			SetServerAddress(SystemAddress& serverAddress);
	void			SetCoordinatorAddress(SystemAddress& serverAddress);
	void			JoinRoom(RakNetGUID& userGuid);
	void			ExitRoom(RakNetGUID& userGuid);
	
	virtual BOOL PreTranslateMessage(MSG* pMsg);

	
	afx_msg void OnBnClickedButtonConnect();	
	afx_msg void OnBnClickedButtonExitRoom();
	
	afx_msg void OnDestroy();
};
